<%@ page language="java" contentType="text/html; charset=UTF-8"
		 pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="tag" tagdir="/WEB-INF/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}" />

<!DOCTYPE html>
<html>
<tag:head title="借阅管理" ctx="${ctx}">
	<link href="${ctx}/assets/css/admin/admin_role_list/style.css" rel="stylesheet">	<!-- 该页面特定的样式 -->
</tag:head>

<tag:body>
	<!-- 左 上 导航 -->
	<tag:nav ctx="${ctx}"></tag:nav>

	<!-- page content -->
	<div class="right_col" role="main">
		<div class="">
			<div class="clearfix"></div>

			<div class="row">
				<div class="col-md-12 col-sm-12 col-xs-12">
					<div class="x_panel">
						<div class="x_title">
							<h2>
								<c:choose>
                                    <c:when test="${requestScope.type == 0}">全部借阅列表</c:when>
									<c:when test="${requestScope.type == 1}">预约列表</c:when>
									<c:when test="${requestScope.type == 2}">已借阅列表</c:when>
									<c:when test="${requestScope.type == 3}">归还列表</c:when>
									<c:when test="${requestScope.type == 4}">完成列表</c:when>
									<c:when test="${requestScope.type == 5}">超期列表</c:when>
									<c:when test="${requestScope.type == 6}">挂失列表</c:when>
								</c:choose>
							</h2>
							<ul class="nav navbar-right panel_toolbox">
								<li>
									<button type="button" class="btn btn-info">全部列表</button>
								</li>
								<li>
									<button type="button" class="btn btn-info">预约列表</button>
								</li>
								<li>
									<button type="button" class="btn btn-info">借出列表</button>
								</li>
								<li>
									<button type="button" class="btn btn-info">归还列表</button>
								</li>
                                <li>
                                    <button type="button" class="btn btn-info">完成列表</button>
                                </li>
								<li>
									<button type="button" class="btn btn-info">超期列表</button>
								</li>
								<li>
									<button type="button" class="btn btn-info">挂失列表</button>
								</li>
							</ul>
							<div class="clearfix"></div>
						</div>
						<div class="x_content">
							<table id="datatable-checkbox" class="table table-striped table-bordered bulk_action">
								<thead>
								<tr>
									<th width="5%"><input type="checkbox" id="check-all"></th>
									<th width="7%" style="display: none;">ID</th>
									<th width="10%">员工号</th>
									<th width="10%">员工名称</th>
									<th width="10%">图书号</th>
									<th width="10%">图书名称</th>
									<th width="10%">类别</th>
									<th width="10%">作者</th>
									<th width="10%">出版社</th>
									<th width="10%">封面图</th>
									<th>开始时间</th>
									<th>结束时间</th>
									<th>已借天数</th>
									<th style="display: none;">该借阅总天数</th>
									<th>状态</th>
									<th width="20%">操作</th>
									<th style="display:none;">书籍价格</th>
									<th style="display: none;">书籍ID</th>
								</tr>
								</thead>

								<tbody>
								<c:forEach var="borrow" items="${requestScope.borrows}">
									<tr>
										<td width="5%"><input type="checkbox"  name="table_records"/></td>
										<td width="7%" style="display: none;">${borrow.borrowId}</td>
										<td width="10%">${borrow.staff.staffId}</td>
										<td width="10%">${borrow.staff.name}</td>
										<td width="10%">${borrow.book.bookId}</td>
										<td width="10%">${borrow.book.name}</td>
										<td width="10%">${borrow.book.bookClass.name}</td>
										<td width="10%">${borrow.book.author}</td>
										<td width="10%">${borrow.book.publish}</td>
                                        <td width="5%"><a href="#" class="btn btn-info btn-xs" data-toggle='modal' data-target='.bigImage' onclick="bigImage('${ctx}/${borrow.book.bookImage}')">
                                            查看大图</a>
                                        </td>
										<td>${borrow.startDate}</td>
										<td>${borrow.endDate}</td>
										<td>${borrow.borrowDays}</td>
										<td style="display: none;">${borrow.allDays}</td>
										<td><c:choose><c:when test="${borrow.state == 0}"><span class="label label-success">取书中</span></c:when>
											<c:when test="${borrow.state == 1}"><span class="label label-primary">借阅中</span></c:when>
											<c:when test="${borrow.state == 2}"><span class="label label-info">归还中</span></c:when>
											<c:when test="${borrow.state == 3}"><span class="label label-default">已归还</span></c:when>
											<c:when test="${borrow.state == 4}"><span class="label label-danger">已超期</span></c:when>
											<c:when test="${borrow.state == 5}"><span class="label label-warning">挂失中</span></c:when>
										</c:choose>
										</td>
										<td width="25%">
											<c:choose>
												<c:when test="${borrow.state == 0 || borrow.state == 2}">
													<a href='javascript:void(0);' class='btn btn-info btn-xs' onclick='ensureBorrow(this)' data-toggle='modal' data-target='.bs-example-modal-eb' ><i class='fa fa-share'></i> 确认 </a>
												</c:when>
												<c:when test="${borrow.state == 4 || borrow.state == 5}">
													<a href='javascript:void(0)' class='btn btn-warning btn-xs' onclick="dealInfo(this,${borrow.state},'${sessionScope.admin.name}')" data-toggle='modal' data-target='.bs-example-modal-lb'><i class='fa fa-share'></i> 处理 </a>
												</c:when>
												<c:when test="${borrow.state == 1}">
													<a href='javascript:void(0)' class='btn btn-warning btn-xs' onclick="urgeReturn(this,'${borrow.borrowId}')"><i class='fa fa-share'></i> 催还 </a>
												</c:when>
											</c:choose>
										</td>
										<td style="display: none;">${borrow.book.price}</td>
										<td style="display: none;">${borrow.book.bookId}</td>
									</tr>
								</c:forEach>
								</tbody>
							</table>
							<div class="dataTables_paginate paging_simple_numbers" id="datatable-checkbox_paginate">
								<ul class="pagination">
									<li class="paginate_button previous disabled" id="datatable-checkbox_previous">
										<a href="javascript:void(0)" aria-controls="datatable-checkbox" data-dt-idx="0" tabindex="0">上一页</a>
									</li>
									<li class="paginate_button next disabled" id="datatable-checkbox_next">
										<a href="javascript:void(0)" aria-controls="datatable-checkbox" data-dt-idx="2" tabindex="0">下一页</a>
									</li>
								</ul>
							</div>
						</div>
					</div>
				</div>

			</div>


		</div>
	</div>
	<!-- /page content -->

	<!-- footer content -->
	<tag:footer></tag:footer>
</tag:body>
<!-- javascript -->
<tag:javascript ctx="${ctx}">
	<!-- this page -->
	<script src="${ctx}/assets/js/admin/admin_borrow_list/admin_borrow_list.js"></script>
	<script>
		<c:if test="${requestScope.error != null}">
			createPNotify("提示信息","error","${requestScope.error}");
		</c:if>
		initTable();
		var buttons = $("button.btn");
        buttons.eq(${requestScope.type}).removeClass("btn-info");
        buttons.eq(${requestScope.type}).addClass("btn-primary");

		<c:choose>
		<c:when test="${requestScope.page.pageSize == 10 || requestScope.page.pageSize == 50 || requestScope.page.pageSize == 25 || requestScope.page.pageSize == 100}">
			$("#pageSize").val(${requestScope.page.pageSize});
		</c:when>
		<c:otherwise>
			$("#pageSize").val("all");
		</c:otherwise>
		</c:choose>

		createPaging($('#datatable-checkbox_paginate'),${requestScope.page.currentPageNum},${requestScope.page.totalPageNum},'borrowList(this,${requestScope.type})',10);
		adjustPagination($("#datatable-checkbox_paginate").children("ul"),${requestScope.page.currentPageNum},${requestScope.page.totalPageNum});
	</script>
</tag:javascript>
</html>

<!-- start:确认操作 -->
<div class="modal fade bs-example-modal-eb" tabindex="-1" role="dialog" aria-hidden="true">
	<div class="modal-dialog modal-sm">
		<div class="modal-content">

			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
						aria-hidden="true">×</span>
				</button>
				<h4 class="modal-title">确认</h4>
			</div>
			<div class="modal-body">
				<h4>确定删除选定的？</h4>
			</div>
			<div class="form-group" style="display: none;">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"></label>
				<div class="col-md-6 col-sm-6 col-xs-12">
					<h4 class="info">成功或失败提示</h4>
				</div>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				<button type="button" class="btn btn-primary">确定</button>
			</div>

		</div>
	</div>
</div>
<!-- end:确认操作 -->

<!-- start:违规操作 -->
<div class="modal fade bs-example-modal-lb" tabindex="-1" role="dialog" aria-hidden="true">
	<div class="modal-dialog modal-sm">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
						aria-hidden="true">×</span>
				</button>
				<h4 class="modal-title">违规处理</h4>
			</div>
			<div class="modal-body postForm">
				<h4 class="red">违规原因:</h4>
				<h4>图书名:<span class="blue"></span></h4>
				<h4>处理费用(书的原价+额外费用):<span id="money" class="postParam red"></span>元</h4>
				<h4>处理人:<span></span></h4>
				<h4>日期:<span id="date" class="postParam"></span></h4>
				<h4 style="display: none;">超期天数:<span class="red"></span></h4>
				<h4 style="display: none;">借阅号:<span id="borrowId" class="postParam"></span></h4>
				<h4 style="display: none;">员工号:<span id="staffId" class="postParam"></span></h4>
				<h4 style="display: none;"><span id="type" class="postParam"></span></h4>
				<h4>罚款计算公式细则:</h4>
				<h4>(挂失)1.0 * 图书原价 + 10.0 + 超期天数 * 0.3 </h4>
				<h4>(超期)超期天数 * 0.3 </h4>
			</div>
			<div class="form-group">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"></label>
				<div class="col-md-6 col-sm-6 col-xs-12">
					<h4 class="info">成功或失败提示</h4>
				</div>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				<button type="button" class="btn btn-primary">确定</button>
			</div>

		</div>
	</div>
</div>
<!-- end:挂失操作 -->

<!-- start:bigImage -->
<div class="modal fade bigImage" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <img src="" width="300px" height="300px">
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>

        </div>
    </div>
</div>
<!-- end:bigImage -->